Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Change crate name (not package name) from loopdev_erikh to loopdev#1

Open
dtolnay wants to merge 1 commit into
erikh:mainfrom
dtolnay-contrib:libname
Open

Change crate name (not package name) from loopdev_erikh to loopdev#1
dtolnay wants to merge 1 commit into
erikh:mainfrom
dtolnay-contrib:libname

Conversation

@dtolnay

@dtolnay dtolnay commented Nov 28, 2023

Copy link
Copy Markdown

By default, Cargo names library crates by taking the Cargo package's name and replacing - by _. So the package here is loopdev-erikh while the library crate contained inside of it is loopdev_erikh.

I propose keeping loopdev-erikh for the package name but using loopdev as the crate name.

# downstream Cargo.toml

[dependencies]
loopdev-erikh = "0.5"
// downstream main.rs

use loopdev::LoopControl;

This is a more convenient way to maintain a fork because the fork becomes a drop-in replacement for the original unmaintained library, without needing to touch Rust source code to change imports or add extern crate loopdev_erikh as loopdev or insert { package = "loopdev" } into Cargo manifests.

@mulkieran

Copy link
Copy Markdown

Note that at present "cargo test" fails. With this change, it succeeds.

@mulkieran

Copy link
Copy Markdown

@dtolnay But, this is not really an "authorized" fork of the original loopdev. How is the problem of the crate name on crates.io handled?

@dtolnay

dtolnay commented Dec 6, 2023

Copy link
Copy Markdown
Author

I don't know what you mean by "authorized fork".

Any Cargo package can contain a crate with any name.

A package cannot have 2 or more direct package dependencies that contain the same crate name.

@mulkieran

Copy link
Copy Markdown

I don't know what you mean by "authorized fork".

Any Cargo package can contain a crate with any name.

A package cannot have 2 or more direct package dependencies that contain the same crate name.

In the past, I've seen people ask to take over a name on crates.io, and then been granted the name. Consequently, I imagined that that was an important step in making a fork. I guess what you are saying is that the name that crates.io uses for its URL is the package name (not the crate name).

@dtolnay

dtolnay commented Dec 6, 2023

Copy link
Copy Markdown
Author

That's right, the names on crates.io are package names not crate names.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants